package org.itboys.db;

import java.io.Serializable;
import java.util.Date;

import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;

/**
 * 关系型数据库统一父类
 * 
 * @author Chenjh
 *
 */
public class BaseEntity implements Serializable{

	private static final long serialVersionUID = 5411043073680296476L;
	
	private Long id; // 主键
	private Date createTime; // 创建时间
	private Date updateTime; // 修改时间

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public String toString() {
		return ToStringBuilder.reflectionToString(this);
	}

	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}

	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		return this.getClass().equals(obj.getClass()) && this.getId() != null
				&& this.getId().equals(((BaseEntity) obj).getId());
	}
}
